#include <iostream>
#include <string>
#include <vector>
#include "FileFinder.h"
using namespace std;



int main() {
    std::cout << "Hello, World!" << std::endl;
    clock_t start,end;
    auto* myHash=new HashList();
    vector <string> files;
    string sd;
    cout<<"choose a directory:"<<endl;
    cin>>sd;
    const char* path=sd.c_str();
    getFiles(path,"txt",files);
    cout<<"HashList Version"<<endl;
    start=clock();

    for(auto & file : files){
        readFiles(file,myHash);
    }
    end=clock();
    auto time=(double)(end-start)/CLOCKS_PER_SEC;
    cout<<"readFinished!    total time:"<<time<<"s"<<endl;
    while(true){
        cout<<"QUERY?(y/n)"<<endl;
        cin>>sd;
        if(sd!="y"&&sd!="Y")
        {break;}
        else{
            cout<<"PROVIDE UR COMMAND!"<<endl;
            myHash->mutiSearch(files);
            cout<<"FINISHED!"<<endl;
        }
    }
    delete myHash;

    cout<<"AVLTree Version"<<endl;
    auto* myTree=new AVLtree();
    start=clock();
    for(auto & file : files){
        readFiles(file,myTree);
    }
    end=clock();
    time=(double)(end-start)/CLOCKS_PER_SEC;
    long t=scan(myTree->root);
    cout<<"readFinished!        total time:"<<time<<"s"<<"      "<<"words:"<<t<<endl;
    while(true){
        cout<<"QUERY?(y/n)"<<endl;
        cin>>sd;
        if(sd!="y"&&sd!="Y")
        {if(sd!="n"&&sd!="N"){
            cout<<"Wrong option!Try again!"<<endl;
                continue;
        }else
            break;
        }
        else{
            cout<<"PROVIDE UR COMMAND!"<<endl;
            myTree->mutiSearch(files);
            cout<<"FINISHED!"<<endl;
        }
    }

    cout<<endl<<"TrieTree Version"<<endl;
    auto* myTrie=new trieTree();
    start=clock();
    for(auto & file : files){
        readFiles(file,myTrie);
    }
    end=clock();
    time=(double)(end-start)/CLOCKS_PER_SEC;
    cout<<"readFinished!        total time:"<<time<<"s"<<endl;
    while(true){
        cout<<"QUERY?(y/n)"<<endl;
        cin>>sd;
        if(sd!="y"&&sd!="Y")
        {if(sd!="n"&&sd!="N"){
                cout<<"Wrong option!Try again!"<<endl;
                continue;
            }else
                break;
        }
        else{
            cout<<"PROVIDE UR COMMAND!"<<endl;
            myTrie->mutiSearch(files);
            cout<<"FINISHED!"<<endl;
        }
    }
    return 0;

}
